<?php
$this->breadcrumbs = array(
    'Workflows' => array('index'),
    'Manage',
);

$this->menu = array(
    array('label' => 'Create Workflow', 'url' => array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('workflow-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Workflows</h1>

<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'workflow-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'selectableRows' => 2,
    'selectionChanged' => "updateSelectors",
    'columns' => array(
        array(
            'class' => 'CCheckBoxColumn',
            'value' => '$data->id',
            'htmlOptions' => array('width' => '3%'),
        ),
        'name',
        'url',
        array(
            'name' => 'creation_datetime',
            'value' => 'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->creation_datetime))',
            'filter' => false,
            'htmlOptions' => array(
                'class' => 'datetime-column'
            )
        ),
        array(
            'name' => 'last_update',
            'value' => 'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->last_update))',
            'filter' => false,
            'htmlOptions' => array(
                'class' => 'datetime-column'
            )
        ),
        array(
            'name' => 'type',
            'value' => '$data->typeText',
            'filter' => false,
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{update} {delete}',
            'buttons' => array(
                'delete' => array(
                    'visible' => '!in_array($data->type, array(1,2))',
                )
            )
        ),
    ),
));

if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array('label' => 'Delete selected items', 'url' => $this->createUrl('delete'), 'linkOptions' => array('onclick' => 'return multipleDelete("workflow-grid",this.href)'));
}
Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl . '/scripts/gridview.js', CClientScript::POS_BEGIN);
?>